# I wrote the original, Mark Dominus optimized it.
# http://blog.plover.com/oops/triangular-phi.html

while(1) { 
  $y += $x++; $r=0;
  for $z (1 .. sqrt($y)) {
    $y % $z == 0 and $r+=2; 
  }
  if ($r>499) {print "$x $y\n";die}
}